<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;

class LoginController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function login()
    {
        return view('admin.login');
        // echo 222;
    }

    public function doLogin(Request $request)
    {
        // dd($_POST['phone']);
        $res = DB::table('users')->where(
                ['phone'=>$_POST['phone'],
                'password'=>$_POST['password']]
            )->first();
        // dd($res);
        if(!empty($res) && ($res->auth != '0')){
           // return response('')->withCookie('uid',$res->id);
            \Cookie::queue('uid',$res->id);
            \Cookie::queue('name',$res->username);
            return redirect('admin/user');
        }
        return back();
    }

    
}
